#pragma once


#define gcodeCfgDir               "$3"                      //步进电机方向
#define gcodeCfgHLimit            "$21"                     //启动硬限位
#define gcodeCfgHoming            "$22"                     //启动归位循环
#define gcodeCfgHomingSpeedH      "$24"                     //归零速度，前段快速移动速度
#define gcodeCfgHomingSpeedL      "$25"                     //归零速度，后段慢速移动速度
#define gcodeCfgTravelResX        "$100"                    //X轴行程分辨率
#define gcodeCfgMaxSpeedX         "$110"                    //X轴最大速度
#define gcodeCfgAccelerationX     "$120"                    //X轴加速度
#define gcodeCfgStrokeX           "$130"                    //X轴最大行程

typedef struct {
    bool dir;
    bool hLimit;
    bool homing;
    int homingSpeedH;
    int homingSpeedL;
    int travelResX;
    int maxSpeedX;
    int accelerationX;
    int strokeX;
}gcodeCfgPara_t;

typedef struct {
    float AxisXPos;
    float AxisYPos;
    float AxisZPos;
}gcodePos_t;

typedef enum{
    Axis1 = 0,
    // Axis2,
    // Axis3,
    // Axis4,
    // Axis5,
    // Axis6,
    // Axis7,
    // Axis8,
    AxisNum,
}MotorAxis_t;

void test_gcode_task(void *pvParameters);

uint16_t gcodeQueries(const char *cmd, char *buf);
uint16_t gcodeSetParameter(bool P1, int P2, const char *cmd, char *buf);
// void gcodeAnalyzeCfg(char *data, gcodeCfgPara_t *saveData);
// uint8_t gcodeAnalyzePos(char *data, double *pos);
bool gcodeAnalyze(char *data, gcodeCfgPara_t *saveData, double *pos);

uint16_t gcodeGoHomeAxis(MotorAxis_t MotorAxis, char *buf);
uint16_t gcodeGoHomeAll(char *buf);
uint16_t gcodeMoveCtrl(MotorAxis_t MotorAxis, int distance, char *buf);
uint16_t gcodeMoveFast(MotorAxis_t MotorAxis, int distance, char *buf);

uint16_t gcodeQuerisePos(char *buf);